#coding:utf-8
__author__ = 'Administrator'
#登录失败会出验证码
#不建议使用
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By

def login(name,pwd):
    email = WebDriverWait(wd,timeout=10).until(EC.presence_of_element_located((By.ID,'email')),message=u'元素加载超时!')
    passwd = WebDriverWait(wd,timeout=10).until(EC.presence_of_element_located((By.ID,'password')),message=u'元素加载超时!')
    submit = wd.find_element_by_id("login")
    email.clear()
    email.send_keys(name)
    passwd.send_keys(pwd)
    submit.click() #点击登录

    if wd.url=='http://www.renren.com/SysHome.do':
        print('false')
    else:
        print('true')

wd = webdriver.Firefox()
wd.get("http://www.renren.com/SysHome.do")

login('545127804@qq.com','8382117')
login('545127804@qq.com','m8382117')


